#ifndef HASIO_DETAIL_REACTOR_OP_HPP
#define HASIO_DETAIL_REACTOR_OP_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include "operation.hpp"
#include "../error.hpp"

namespace hasio {
namespace detail {

class reactor_op
    : public operation
{
public:
    enum status
    {
        not_done = 0,
        done,
    };

    status perform()
    {
        return perform_func_(this);
    }

protected:
    typedef status (*perform_func_type)(reactor_op*);

    reactor_op(perform_func_type perform_func, func_type complete_func
        , const hasio::error_code &ec)
        : operation(complete_func)
        , ec_(ec)
        , perform_func_(perform_func)
    {}
    
public:
    hasio::error_code ec_;
private:
    perform_func_type perform_func_;
};

}
}

#endif // HASIO_DETAIL_REACTOR_OP_HPP